﻿using System;
using Niknak.Services.ServiceCore.TaskScheduler;

namespace Niknak.Services.TaskScheduler.Interfaces
{
    public interface ITaskProcessor<ConfigType, AuditLogType, AuditLogEntryType> : IFindableTaskProcessor
        where ConfigType : new()
        where AuditLogType : DataModel.IAuditLog<AuditLogEntryType>, new()
        where AuditLogEntryType : DataModel.IAuditLogEntry
    {
        /// <summary>
        /// Method called to process each iteration of the task.
        /// </summary>
        Enums.TaskOutcome ProcessTask(ConfigType config, AuditLogType currentLog, ref bool terminate);

        void Processor_Load(string startArguments);

        event EventHandler<IterationEventArgs> TaskIterationStarting;
        event EventHandler<IterationEventArgs> TaskIterationTerminationRequest;
        event EventHandler<IterationEventArgs> TaskIterationCompleted;
        event EventHandler TaskShuttingDown;
        event EventHandler<LoggingEventArgs> TaskLogMessageGenerated;

        void RaiseTaskIterationStartingEvent(object sender, ServiceCore.TaskScheduler.IterationEventArgs eventArgs);
        void RaiseTaskIterationTerminationRequestEvent(object sender, ServiceCore.TaskScheduler.IterationEventArgs eventArgs);
        void RaiseTaskIterationCompletedEvent(object sender, ServiceCore.TaskScheduler.IterationEventArgs eventArgs);
        void RaiseTaskShuttingDownEvent(object sender, EventArgs eventArgs);
        void RaiseTaskLogMessageGeneratedEvent(object sender, ServiceCore.TaskScheduler.LoggingEventArgs eventArgs);
    }
}
